package com.wc.alorithm_blue_bridge._数学知识.质数.包子凑数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

/**
 * @Author congge
 * @Date 2023/11/13 20:18
 * @description 包子凑数
 * https://www.lanqiao.cn/problems/98/learning/?page=1&first_category_id=1&second_category_id=3&tags=%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92
 */
public class Main {
    public static void main(String[] args) {
        Input sc = new Input();
        int n = sc.nextInt();
        int[] array = new int[n];
        array[0] = sc.nextInt();
        int maxGcd = array[0];
        for (int i = 1; i < n; i++) {
            array[i] = sc.nextInt();
            maxGcd = gcd(maxGcd, array[i]);
        }
        /**
         * 当所有数字没有互质的情况，凑不出的数字就是无限多个
         * 因为两个互质的数最大不能表示的数为（a - 1） * (b - 1) - 1
         */
        if (maxGcd != 1) {
            System.out.println("INF");
        } else {
            /**
             * 根据题目提示 1<= A <=100
             */
            boolean[] dp = new boolean[10001];
            // 整数倍可以表示
            for (int i = 0; i < n; i++) {
                for (int j = 1; j < dp.length; j++) {
                    if (j % array[i] == 0) {
                        dp[j] = true;
                    }
                }
            }
            // 这里i为什么从1开始array[0]与他本身相加不就是上面的倍数嘛，减少重复第一项工作
            for (int i = 1; i < n; i++) {
                for (int j = 1; j < dp.length; j++) {
                    if (dp[j]) {
                        // 开始混 +
                        if (j + array[i] < dp.length) {
                            dp[j + array[i]] = true;
                        }
                    }
                }
            }
            int ans = 0;
            // 开始记录答案
            for (int i = 1; i < dp.length; i++) {
                if (!dp[i]){
                    ans++;
                }
            }
            System.out.println(ans);
        }
    }

    public static int gcd(int num1, int num2) {
        if (num1 == 0) {
            return num2;
        }

        return gcd(num2 % num1, num1);
    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return (int) in.nval;
        }
    }
}
